home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-25 | 7.8 KB | 244 lines | [TEXT/EDIT] |
- INTRO:
-
- Introduction to RLaB "Our"-LaB.
-
- RLaB is a vector and matrix oriented, interactive, interpreted
- programming LANGUAGE. Although RLaB started as an effort to
- functionally replace MATLAB, the language and functions are
- NOT MATLAB replicas. Although the language is similar to
- MATLAB in some ways there are numerous differences (I hope for
- the better). The help file MATLAB_DIFF briefly discusses the
- primary differences between RLaB and MATLAB. If you are a
- MATLAB expert please read the MATLAB_DIFF file ASAP.
-
- The RLaB Primer is also a good starting point for new users.
- It is short, and provides many introductory examples.
-
- Using RLaB:
-
- To get this far you must already be running RLaB. At this
- point you are using the command line interface. When RLaB
- confronts you with the command line prompt (`>') it is ready
- to accept any valid statement. As soon as a valid statement is
- recognized, RLaB will execute it. For example
-
- > a = sqrt(2)
- a =
- 1.41
-
- The right-hand-side (RHS) of the expression is evaluated, and
- the result is assigned to `a' immediately.
-
- There are several data types. You do NOT need to declare
- variable types, just use them (the variable(s)) in the proper
- context. In the previous example `a' was a scalar. In the
- following example `a' will be used as a matrix:
-
- > a = [1,2,3;4,5,6;7,8,9]
- a =
- matrix columns 1 thru 3
- 1 2 3
- 4 5 6
- 7 8 9
-
- The previous example created a matrix and stored it in the
- variable (entity) `a'. The previous entity that `a'
- represented (sqrt(2)) is destroyed.
-
- You can use most math operators like you would in C:
-
- a + b Addition
- a - b Subtraction
- a * b Matrix Multiplication
- a .* b Matrix element-by-element multiply
- a / b Right Division
- a ./ b Element-by-element Right Division
- a \ b Left Division
- a .\ b Element-by-element Left Division
- a^b Power
- a.^b Element-by-element power
- -a Unary minus (negation)
- +a Unary plus
- a' Matrix transpose (Hermitian transpose)
- a.' Matrix element-by-element transpose
-
- To see all of the available functions type `what()'. Try using
- some:
-
- > what()
- abs diag int pause solve
- acos diary int2str pclose sort
- acosh diff intersection phrd sprintf
- all disp inv plot sqrt
- any dot isempty printf srand
- asin eig isinf printmat std
- asinh epsilon isnan prod strsplt
- atan error issymm qr sum
- atan2 eval length rand svd
- atanh exist linspace rank sylv
- backsub exp load rcond symm
- balance eye log read system
- cd factor log10 readm tan
- ceil fft logspace real tanh
- chol find lu redit tic
- class finite lyap reshape tmp_file
- clear fix matrix round toc
- clearall floor max save trace
- close format maxi scalar tril
- compan fprintf mean schur triu
- complement fvscope members set type
- conj getline min setterm union
- cos hess mini show what
- cosh hilb mod showplot who
- cross ifft nan sign whos
- cumprod imag norm sin write
- cumsum inf num2str sinh writem
- det input ones size zeros
-
- 1st enter a matrix:
-
- > a = [1,2,3;4,5,6;7,8,9]
- a =
- matrix columns 1 thru 3
- 1 2 3
- 4 5 6
- 7 8 9
-
- Then transpose it:
-
- > b = a'
- b =
- matrix columns 1 thru 3
- 1 4 7
- 2 5 8
- 3 6 9
-
- Then perform matrix multiplication with the two matrices:
-
- > c = a * b
- c =
- matrix columns 1 thru 3
- 14 32 50
- 32 77 122
- 50 122 194
-
- Do an element - by - element multiply:
-
- > d = a .* b
- d =
- matrix columns 1 thru 3
- 1 8 21
- 8 25 48
- 21 48 81
-
- Zero out the element of a that is in the 3rd row, 3rd column.
-
- > a[3;3] = 0
- a =
- matrix columns 1 thru 3
- 1 2 3
- 4 5 6
- 7 8 0
-
- Use det() to compute the value of the determinant of [a].
-
- > det(a)
- 27
-
- Use another built-in function to estimate the reciprocal of
- the condition number:
-
- > rcond(a)
- 0.01935
- > 1/rcond(a)
- 51.67
-
- Use another built-in function to compute the matrix inverse:
-
- > inv(a)
- matrix columns 1 thru 3
- -1.778 0.8889 -0.1111
- 1.556 -0.7778 0.2222
- -0.1111 0.2222 -0.1111
-
- Use yet another to compute the eigenvalues, and eigenvectors
- of [a]:
-
- > eig( [1,2,3;4,5,6;7,8,9] )
- val vec
-
- Notice that eig() appears to return two variables, val, and
- vec. Actually eig() returns a LIST. A LIST is an entity that
- contains other entities. Functions that need to return more
- than one entity do so via a LIST. See `help LIST' if LISTs are
- confusing you.
-
- The members of a list are accessed via a special syntax.
-
- list . lname
-
- will reference the member of the list with a name equal to
- lname. For example:
-
- > eig([1,2,3;4,5,6;7,8,9]).val
- val =
- matrix columns 1 thru 3
- 16.1 + 0i -1.12 + 0i -8.46e-16 + 0i
-
- will return the eigenvalues of the input. If you want to save
- the entire list, then save it in a variable.
-
- > a = eig([1,2,3;4,5,6;7,8,9])
- val vec
-
- Then you can access the members of the list:
-
- > a.val
- val =
- matrix columns 1 thru 3
- 16.1 + 0i -1.12 + 0i -8.46e-16 + 0i
-
- > a.vec
- vec =
- matrix columns 1 thru 3
- 0.232 + 0i 0.786 + 0i 0.408 + 0i
- 0.525 + 0i 0.0868 + 0i -0.816 + 0i
- 0.819 + 0i -0.612 + 0i 0.408 + 0i
-
- If you want to know what the names of the list members are you
- can simply type the list variable at the prompt:
-
- > a
- val vec
-
- Or, you can use the members function:
-
- > members(a)
- val vec
-
- To see what variables are in the workspace, type `who()'
-
- > who()
- a c pi
- b d pinfo
-
- A variable can be removed from the workspace, and it's memory
- freed, with the clear function:
-
- > clear(a, d)
- 2
- > who()
- b c pi pinfo
-
- Clear returns a number that signifies how many objects were
- cleared from the workspace.
-
- At this point you should be starting to get an idea of some of
- the things RLaB can do, even though we have not yet introduced
- logical operators, conditional statements, looping statements,
- and user-functions.
-
- Please skim through all the help files that are spelled with
- capital letters. This will acquaint you with more features and
- let you know where to go for help in the future.
-